As you have just seen, all .NET web pages eventually derive from System.Web.UI.Page. Like any base class, this type provides a polymorphic interface to all derived types. However, the Page type is not the only member in your inheritance hierarchy. If you were to locate the System.Web.UI.Page class (within the System.Web.dll assembly) using the Visual Studio 2010 object browser, you would find that Page is-a TemplateControl, which is-a Control, which is-a Object (see Figure 32-23).
Figure 32-23 The inheritance chain of Page
Each of these base classes brings a good deal of functionality to each and every *.aspx file. For the majority of your projects, you will make use of the members defined within the Page and Control parent classes. The functionality gained from the System. Web.UI.TemplateControl class is only of interest if you are building custom Web Form controls or interacting with the rendering process.
The first parent class of interest is Page itself. Here you will find numerous properties that enable you to interact with various web primitives such as application and session variables, the HTTP request/ response, theme support, and so forth. Table 32-4 describes some (but by no means all) of the core properties.
Table 32-4. Select Properties of the Page Type
Property | Meaning in Life |
---|---|
Application | Allows you to interact with data that can be accessed across the entire website for all users |
Cache | Allows you to interact with the cache object for the current website |
ClientTarget | Allows you to specify how this page should render itself based on the requesting browser |
IsPostBack | Gets a value indicating whether the page is being loaded in response to a client postback or whether it is being loaded and accessed for the first time |
MasterPageFile | Establishes the master page for the current page |
Request | Provides access to the current HTTP request |
Response | Allows you to interact with the outgoing HTTP response |
Server | Provides access to the HttpServerUtility object, which contains various serverside helper functions |
Session | Allows you to interact with the session data for the current caller |
Theme | Gets or sets the name of the theme used for the current page |
Trace | Provides access to a TraceContext object, which allows you to log custom messages during debugging sessions |